/**
    Copyright (C) 2011  Alexander Vollmer

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.jefb.web.model;

import java.io.File;
import java.io.Serializable;

import org.jefb.entity.FileEntity;

public class FileDataHolder implements Comparable<FileDataHolder>, Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private File file;
	private FileEntity fileEntity;
	private String fileName;
	private Boolean isFile;

	public FileDataHolder() {
		super();
	}

	public FileDataHolder(File file) {
		this.file = file;
	}

	public File getFile() {
		return file;
	}

	public void setFile(File file) {
		this.file = file;
	}

	public FileEntity getFileEntity() {
		return fileEntity;
	}

	public void setFileEntity(FileEntity fileEntity) {
		this.fileEntity = fileEntity;
	}

	public int compareTo(FileDataHolder fh) {
		if (this.getFile().isDirectory() && fh.getFile().isDirectory()) {
			return this.getFile().getName().compareTo(fh.getFile().getName());
		} else if (this.getFile().isDirectory() && fh.getFile().isFile()) {
			return -1;
		} else if (this.getFile().isFile() && fh.getFile().isFile()) {
			return this.getFile().getName().compareTo(fh.getFile().getName());
		} else {
			return 1;
		}
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getFileName() {
		return fileName;
	}

	public void setIsFile(Boolean isFile) {
		this.isFile = isFile;
	}

	public Boolean getIsFile() {
		return isFile;
	}

}
